/*
 * Created on 18-Jun-2006
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package Jona;

/**
 * @author Administrator
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class PowerConditional extends Conditional {
	/**
	 * Creates a new powerful conditional "antecedent -> consequent"
	 * @param antecedent Antecedent of the conditional
	 * @param consequent Consequent of the conditional
	 */
	public PowerConditional(ArgObject antecedent, ArgObject consequent) {	
		super(antecedent, consequent);
	}
	
	/**
	 * Creates a new powerful conditional "antecedent -> consequent" with the given
	 * supporter and attacker relations
	 * @param antecedent Antecedent of the conditional
	 * @param consequent Consequent of the conditional
	 * @param supporters Array of the conditional's supporters
	 * @param attackers Array of the conditional's attackers
	 */
	public PowerConditional(ArgObject antecedent, ArgObject consequent, ArgObject[] supporters, ArgObject[] attackers) {	
		super(antecedent, consequent, supporters, attackers);
	}
	
	/**
	 * Creates a new powerful conditional with the given type and consequent
	 * @param argumentType ArgObject.UNDEFINED, ArgObject.ASSUMPTION or ArgObject.ISSUE
	 * @param consequent ArgObject consequent of the conditional
	 */
	public PowerConditional(int argumentType,ArgObject consequent) {
		super(argumentType,consequent);
	}

	public int evaluate(Theory th){
		int retVal, i;
		retVal = super.evaluate(th);
		ArgObject [] opposers = consequent.getAttackingConditionals();
		if (retVal == ArgObject.EVALUATION_UNDEFEATED) {
			for (i = 0; i < opposers.length; ++i) {
				if (!(opposers[i] instanceof PowerConditional)) {
					th.setValue(opposers[i],ArgObject.EVALUATION_DEFEATED);
				}
			}
		}
		return retVal;
	}
}
